#include <pthread.h>
#include <stdio.h>
#include <unistd.h>

#define MAX_CYCLE_NUM 50000

int g_Num = 0;

void * FunTest1( void * arg )
{
    int i;
    for( i=0; i<MAX_CYCLE_NUM; i++ )
    {
        g_Num++;
    }
    printf( "g_Num from 1: %d\n", g_Num );

    return NULL;
}


void * FunTest2( void * arg )
{
    int i;
    for( i=0; i<MAX_CYCLE_NUM; i++ )
    {
        g_Num++;
    }
    printf( "g_Num from 2: %d\n", g_Num );

    return NULL;

}

int main(int argc, char const *argv[])
{
    pthread_t tpidFunTest1;
    pthread_t tpidFunTest2;

    pthread_create( &tpidFunTest1, NULL, FunTest1, NULL );
    pthread_create( &tpidFunTest2, NULL, FunTest2, NULL );

    pthread_join( tpidFunTest1, NULL );
    pthread_join( tpidFunTest2, NULL );


    return 0;
}
